function showModal(msg) {
  return new Promise(function(resolve, reject) {
    uni.showModal({
      title: '温馨提示',
      content: msg,
      showCancel: true,
      cancelColor: '#D9D9D9',
      confirmColor: '#0566A8',
      success: function(res) {
        resolve(res)
      },
      fail: function(res) {
        reject(res)
      }
    })
  })
}

function showConfirmModal(msg) {
  return new Promise(function(resolve, reject) {
    uni.showModal({
      title: '温馨提示',
      content: msg,
      showCancel: false,
      confirmColor: '#0566A8',
      success: function(res) {
        resolve(res)
      },
      fail: function(res) {
        reject(res)
      }
    })
  })
}

function showToast(msg) {
  uni.showToast({
    title: msg,
    icon: 'none',
    duration: 2000
  })
}

function showSuccessToast(msg) {
  uni.showToast({
    title: msg,
    duration: 2000
  })
}

function showErrorToast(msg) {
  uni.showToast({
    title: msg,
    image: '/static/images/icon/icon_error.png',
    duration: 2000
  })
}

export default {
  showModal,
  showConfirmModal,
  showToast,
  showSuccessToast,
  showErrorToast
}
